package com.lsh.airticket.service.impl;

import com.lsh.airticket.dao.ModelSpaceDao;
import com.lsh.airticket.entity.ModelSpace;
import com.lsh.airticket.entity.OneModelAllSpace;
import com.lsh.airticket.service.ModelSpaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * @author lsh
 * @date 2021/2/18
 **/
@Service
public class ModelSpaceServiceImpl implements ModelSpaceService {

    @Autowired
    ModelSpaceDao modelSpaceDao;

    @Override
    public List<OneModelAllSpace> ModelSpaceDao(Integer modelId) {
        return modelSpaceDao.findModelIdBySpace(modelId);
    }

    @Override
    public int insertTbModelSpace(ModelSpace modelSpace) {
        modelSpace.setModelCreatetime(new Date());
        int i = modelSpaceDao.insertTbModelSpace(modelSpace);
        return i;
    }

    @Override
    public int deleteModelSpaceById(Integer modelId, Integer spaceId) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("modelId",modelId);
        map.put("spaceId",spaceId);
        return modelSpaceDao.deleteByModelSpaceId(map);
    }
}
